package com.plian.system.controller.hr.parttimedismissal;

import com.plian.Tools.base.BaseController;
import com.plian.system.service.hr.recruitment.INewPartTimeManagementService;
import com.plian.system.wrapper.hr.recruitment.PartTimeManagementWrapper;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 兼职管理
 *
 * @author BladeX
 * @since 2019-12-02
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("api/newparttimemanagement")
@Api(value = "兼职管理", tags = "兼职管理")
public class NewPartTimeManagementController extends BaseController {

    private INewPartTimeManagementService partTimeManagementService;

    private PartTimeManagementWrapper partTimeManagementWrapper;

//    /** TODO DEL
//     * 新增或修改
//     */
//    @ApiOperation(value = "新增或修改", notes = "新增或修改")
//    @ApiResponses({
//            @ApiResponse(code = 200, message = "操作成功"),
//            @ApiResponse(code = 1999, message = "操作失败"),
//    })
//    @PostMapping("/submit")
//    @Resubmit(delaySeconds = 0)
//    public R submit(@RequestBody PartTimeManagement partTimeManagement) {
//        String checkMessage = partTimeManagementService.checkSubmit(partTimeManagement);
//        if (StringUtil.isNotBlank(checkMessage)) {
//            return new R(CustomCode.builder().message(checkMessage).code(1999).success(false).build());
//        }
//        return partTimeManagementService.submit(partTimeManagement)
//                ? new R(CommonCode.SUCCESS) : new R(CommonCode.FAIL);
//    }
//
//    /**
//     * 详情
//     */
//    @ApiOperation(value = "详情", notes = "详情")
//    @ApiResponses({
//            @ApiResponse(code = 200, message = "操作成功"),
//            @ApiResponse(code = 1999, message = "操作失败"),
//    })
//    @PostMapping("/detail")
//    public ObjResult detail(@RequestBody PartTimeManagement partTimeManagement) {
//        PartTimeManagement detail = partTimeManagementService.getOne(Condition.getQueryWrapper(partTimeManagement));
//        PartTimeManagementVO partTimeManagementVO = partTimeManagementWrapper.entityToVO(detail);
//        return partTimeManagementService.getDetailObj(partTimeManagementVO);
//    }
//
//    /**
//     * 列表
//     */
//    @ApiOperation(value = "列表", notes = "列表")
//    @ApiResponses({
//            @ApiResponse(code = 200, message = "操作成功"),
//            @ApiResponse(code = 1999, message = "操作失败"),
//    })
//    @PostMapping("/list")
//    public ListResult<PartTimeManagementVO> list(@Valid @RequestBody Query query) {
//        if (query.getAscs() == null && query.getDescs() == null) {
//            query.setDescs("create_time");
//        }
//        List<SearchEntity> entityList = query.getSearch();
//        QueryWrapper<PartTimeManagement> queryWrapper = SearchParamEntiy.getQueryWrapper(
//                Condition.getQueryWrapper(new PartTimeManagement()), entityList
//        );
//        TokenSearch<PartTimeManagement> tokenSearch = new TokenSearch<>();
//		tokenSearch.addTokenQuery(queryWrapper, query);
//        IPage<PartTimeManagement> pages = partTimeManagementService.page(Condition.getPage(query), queryWrapper);
//        List<PartTimeManagementVO> partTimeManagementVOS = partTimeManagementWrapper.entityToVO(pages.getRecords());
//        ListResult<PartTimeManagementVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//        listResult.setList(partTimeManagementVOS);
//        listResult.setTotal(Long.valueOf(pages.getTotal()).intValue());
//        return listResult;
//    }
//
//    /**
//     * 删除
//     */
//    @ApiOperation(value = "删除", notes = "删除")
//    @ApiResponses({
//            @ApiResponse(code = 200, message = "操作成功"),
//            @ApiResponse(code = 1999, message = "操作失败"),
//    })
//    @PostMapping("/remove")
//    public R remove(@RequestBody PageData pd) {
//        List<String> ids = (List<String>) pd.get("ids");
//        return partTimeManagementService.deleteLogic(Func.toLongList(StringUtils.join(ids, StringPool.COMMA)))
//                ? new R(CommonCode.SUCCESS) : new R(CommonCode.FAIL);
//    }
//
//
//    /**
//     * 已兼职情况
//     */
//    @ApiOperation(value = "已兼职信息", notes = "已兼职信息")
//    @ApiResponses({
//            @ApiResponse(code = 200, message = "操作成功"),
//            @ApiResponse(code = 1999, message = "操作失败"),
//    })
//    @PostMapping("/selectAlreadyPartTimeInfo")
//    public R selectAlreadyPartTimeInfo(@RequestBody PartTimeInfo partTimeInfo) {
//        return R.data(partTimeManagementService.selectPartTimeInfoStatus(partTimeInfo.getStaffNameId(), PartTimeStatus.INCUMBENCY.getStatus()));
//    }
//
//
//    /**
//     * 下一步预览pdf数据
//     */
//    @ApiOperation(value = "下一步预览pdf数据", notes = "下一步预览pdf数据")
//    @ApiResponses({
//            @ApiResponse(code = 200, message = "操作成功"),
//            @ApiResponse(code = 1999, message = "操作失败"),
//    })
//    @PassToken
//    @PostMapping(value = "/nextPdf", produces = "application/json;charset=UTF-8")
//    public ResponseEntity<FileSystemResource> nextPdf(@RequestBody PartTimeManagement partTimeManagement) {
//        return FileTools.exportPdf(partTimeManagementService.nextPdf(partTimeManagement));
//    }
//
//    /**
//     * 预览(企业审批表详情社会团体审批表)
//     */
//    @GetMapping("/buildpdf/{id},{type}")
//    @PassToken
//    public ResponseEntity<FileSystemResource> buildpdf(@PathVariable Long id, @PathVariable Integer type) {
//        return FileTools.exportPdf(partTimeManagementService.buildpdf(id, type));
//    }
//
//    /**
//     * 测试
//     */
//    @PostMapping("/testData")
//    public void testExport(@RequestParam("data") String data) {
//        partTimeManagementService.savePartTimeManagementReform(data);
//    }


    /**
     * 导出(企业审批表详情社会团体审批表)
     *
     * @param response
     */
    @PostMapping("/export")
//    @PassToken
    public void testExport(@RequestBody Map<String, Object> params, HttpServletResponse response) {
        Long id = Long.parseLong(String.valueOf(params.get("id")));
        Integer type = Integer.parseInt(String.valueOf(params.get("type")));
        partTimeManagementService.export(id, type, response);
    }

}
